package com.verlet.configclient.controller;

import com.verlet.configclient.message.StreamReceiver;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author verlet
 * @date 2018/8/4
 */
@Slf4j
@RefreshScope
@RestController
public class ConfigController {

    @Value("${foo}")
    String foo;

    @RequestMapping(value = "/hi")
    public String hi() {
        return foo;
    }


    @Autowired
    private StreamReceiver streamReceiver;

    @RequestMapping(value = "/send")
    public String send() {
        Map<String,Object> map = new HashMap<>();
        streamReceiver.send("这是一条消息",map);
        return "SUCCESS";
    }
}
